﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class ParserGui : Form
    {
        Playerstats.Parser pr = null;
        public ParserGui()
        {
            InitializeComponent();
            timer1 = new Timer();
            timer1.Interval = 86400000;
            timer1.Tick += new EventHandler(timer1_Tick);
            pr = new Playerstats.Parser();
            timer1.Enabled = true;
          //  pr.ParsePlayerList();      
        }

        void pr_OnePageParsed(object sender, EventArgs e)
        {

                ListViewItem LI = new ListViewItem(DateTime.Now.ToString());
                listView1.Items.Add(LI);
                listView1.EnsureVisible(listView1.Items.Count - 1);
                    listView1.Refresh();
            
        }

        void timer1_Tick(object sender, EventArgs e)
        {
            pr.ParseSQLFile("http://s2.travian.fi/map.sql", Playerstats.Parser.Server.s2fi);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            pr.ParseSQLFile("http://s2.travian.fi/map.sql", Playerstats.Parser.Server.s2fi);
        }

        private void ParserGui_RegionChanged(object sender, EventArgs e)
        {
           

        }

        private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            Show();
            WindowState = FormWindowState.Normal;

        }

        private void ParserGui_Resize(object sender, EventArgs e)
        {
            if (FormWindowState.Minimized == WindowState)
                Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            pr.DeleteDead();
        }
    }
}
